﻿<%@ Page Language="C#" MasterPageFile="~/SimplePMT.Master" AutoEventWireup="true" CodeBehind="TaskSearch.aspx.cs" Inherits="SimplePMT.TaskSearch" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="MainContent">
    <form id="searchForm" name="searchForm">
    <table width="100%" cellpadding=3>
        <tr>
            <td style="white-space:nowrap;color:#ffffff" bgcolor="#869AAE"><b>Task Search</b></td>
        </tr>
        <tr>
            <td style="border:1px solid #6893cf;" valign=top bgcolor="#ffffff">
                <table width=90% align=center>
                    <tr>
                        <td colspan="4" width=100% bgcolor="#CACACA" style="color:#ffffff" align=left><b>Search For Tasks:</b></td>
                    </tr>
                    <tr>
                        <td colspan="4" height=5></td>
                    </tr>
                    <tr>
                        <td><b>Search By: </b></td>
                        <td valign=top>
                            <select id="SearchBy" name="SearchBy" style="width:160px" onKeyPress = "return entersubmit(event)">
                                <option value="ID">Task ID</option>
                                <option value="Title">Title</option>
                                <option value="Description">Description</option>
                                <option value="Notes">Notes</option>
                            </select>
                        </td>
                        <td>
                            &nbsp;&nbsp;<b>Search For:</b>
                        </td>
                        <td>
                            <input type="text" id="SearchFor" name="SearchFor" value="" size=25  onKeyPress = "return entersubmit(event)" />
                            &nbsp;&nbsp;<button type="button" id="SearchButton" onclick="search()">Search</button>
                        </td>
                    </tr>
                    <tr>
                        <td colspan=4 height=4></td>
                    </tr>
                    <tr>
                        <td colspan=4 height=1 bgcolor="#CACACA"></td>
                    </tr>
                    <tr>
                        <td colspan=4 height=5></td>
                    </tr>
                    <tr>
                        <td id="SearchResults" colspan=4>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        
    </table>
    </p>
    <script>
        function entersubmit(e) {
            var keycode;
            if (window.event) keycode = window.event.keyCode;
            else if (e) keycode = e.which;
            else return true;

            if (keycode == 13) {
                search();
                return false;
            }
        }
    
    function search() {
        var df = document.searchForm;
        SimplePMT.TaskSearch.Search(df.SearchBy.options[df.SearchBy.selectedIndex].value, df.SearchFor.value, function(response) {
            if (response.error != null) {
                alert(response.error.Message);
            } else {
                document.getElementById('SearchResults').innerHTML = response.value;
            }
        });
    }
</script>
</asp:Content>